<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('微信用户列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>手机号：</label>
                            <input type="text" name="phoneNum" />
                        </li>
                        <li>
                            <label>归属单位：</label>
                            <input type="text" name="shopCompany"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="toMySearch()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="toSendAll()" > <i class="fa fa-adjust"></i> 全部发放
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('WxUser:WxUser:edit')}]];
    var removeFlag = [[${@permission.hasPermi('WxUser:WxUser:remove')}]];
    var sexDatas = [[${@dict.getType('sys_user_sex')}]];
    var isVipDatas = [[${@dict.getType('is_vip')}]];
    var isAlShopDatas = [[${@dict.getType('is_al_shop')}]];
    var prefix = ctx + "WxUser/WxUser";
    var couponId = [[${couponId}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            modalName: "微信用户",
            rememberSelected: true,
            columns: [{
                field: 'state',
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'null',
                    visible: false
                },
                {
                    field: 'nickName',
                    title: '昵称'
                },
                {
                    field: 'sex',
                    title: '性别',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(sexDatas, value);
                    }
                },
                {
                    field: 'avater',
                    title: '头像',
                    formatter: function (value, row, index) {
                        return '<img style="border-radius: 50%;width: 50px;height: 50px" src="' + value + '">'
                    }
                },
                {
                    field: 'phoneNum',
                    title: '手机号'
                },
                {
                    field: 'jiFen',
                    title: '积分'
                },
                {
                    field: 'ownMoney',
                    title: '余额'
                },
                {
                    field: 'isAlShop',
                    title: '是否归属商家',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isAlShopDatas, value);
                    }
                },
                {
                    field: 'shopCompany',
                    title: '归属单位'
                },
                {
                    field: 'createTime',
                    title: '注册时间'
                }]
        };
        $.table.init(options);
    });

    function submitHandler() {
        var arrays = $.table.selectColumns("id").toString();
        $.modal.confirm("是否确认发放此优惠券", function () {
            $.post(ctx + "onlineCoupon/onlineCoupon/sendCouponToVip", {
                couponId: couponId,
                wids: arrays
            }, function (result) {
                $.operate.saveSuccess(result);
            })
        })
    }
    /*搜索*/
    var data={}
    function toMySearch() {
        data={};
        data.phoneNum = $("input[name='phoneNum']").val()
        data.shopCompany = $("input[name='shopCompany']").val()
        $.table.search()
    }


    //全部发放
    function toSendAll() {
        $.modal.confirm("是否确认发放此优惠券给当前所有人", function () {
            data.couponId =couponId;
            console.log(data)
            $.post(ctx + "onlineCoupon/onlineCoupon/toSendAll", data, function (result) {
                $.operate.saveSuccess(result);
            })
        })
    }


</script>
</body>
</html>